﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;
using DAO;

namespace BUS
{
    public class BUSDangNhap
    {

        public static DTONguoiDung ThongTinNguoiDung(string username)
        {
            try
            {
                DataTable ketqua = DAONguoiDung.ThongTinNguoiDung(username);
                if (ketqua.Rows.Count > 0)
                {
                    DTONguoiDung nguoidung = new DTONguoiDung();
                    nguoidung.UserId = int.Parse(ketqua.Rows[0][0].ToString());
                    nguoidung.UserName = ketqua.Rows[0][1].ToString();
                    nguoidung.Password = ketqua.Rows[0][2].ToString();
                    nguoidung.VaiTro = ketqua.Rows[0][3].ToString();
                    nguoidung.TrangThai = bool.Parse(ketqua.Rows[0][4].ToString());
                    return nguoidung;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
